import Taro, { Component } from '@tarojs/taro'

import { connect } from '@tarojs/redux'
import actions from '../../store/actions'

import Week from '../../components/Week'

const { getAnime } = actions

@connect(({ animeData }) => ({
  animeData
}))
class Index extends Component {
  config = {
    navigationBarTitleText: '首页'
  }

  componentDidMount() {
    const { dispatch, animeData } = this.props
    !(animeData.data && animeData.data.length) // && Taro.showLoading({ title: '加载中' })
    animeData.data && animeData.data.length
      ? null
      : dispatch(getAnime()).then(data => {
          // console.log(data, '加载完')
          // Taro.hideLoading()
        })
  }

  componentDidHide() {}

  render() {
    const { animeData } = this.props
    return <Week data={animeData.data} />
  }
}

export default Index
